package com.sinosoft.web.common.servlet;

import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.HttpServletBean;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2016/6/24.
 */
public class ServerInfoServlet extends HttpServletBean {

    private PathMatcher pathMatcher;


    protected void initServletBean() {
        this.pathMatcher = getPathMatcher();
    }

    /**
     * Return a PathMatcher to use for matching the "allowedResources" URL pattern.
     * Default is AntPathMatcher.
     *
     * @see org.springframework.util.AntPathMatcher
     */
    protected PathMatcher getPathMatcher() {
        return new AntPathMatcher();
    }


    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String url = req.getRequestURI();
        int last = url.lastIndexOf(".");
        url = url.substring(url.lastIndexOf("/") + 1, last);
        req.getRequestDispatcher("/WEB-INF/server/" + url + ".jsp").include(req, resp);
//        super.doGet(req, resp);
    }
}
